package org.netEase.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.netEase.dao.shoptypeDao;
import org.netEase.entity.goodsType;
import org.netEase.entity.shangping;
import org.netEase.entity.typegg;
import org.netEase.util.BaseDao;

public class shoptypeDaoImple extends BaseDao implements shoptypeDao {

	@Override
	public goodsType listGetBySid(int sid) {
		String sql = "SELECT sh.spgId,sh.spgValues,sh.spgValues2,sh.Sid,s.Zid,s.simg,s.bigimg,s.Sname,s.Sjiage,s.jieshao,s.Simgss,s.jifen,s.commentCount,t.tgName FROM shopgg sh INNER JOIN shangping s ON sh.Sid=s.Sid INNER JOIN typegg t ON sh.tgId=t.tgId WHERE sh.Sid = ?";
		ResultSet rs = super.executeQuery(sql, sid);
		goodsType goodsType =null;
		try {
			while (rs.next()) {
				goodsType = new goodsType();
				goodsType.setSpgid(rs.getInt("spgid"));
				shangping  shangping = new shangping();
				shangping.setZid(rs.getInt("zid"));
				shangping.setShopimage(rs.getString("simg"));
				shangping.setBigimg(rs.getString("bigimg"));
				shangping.setShopname(rs.getString("Sname"));
				shangping.setSjiage(rs.getDouble("sjiage"));
				shangping.setJieshao(rs.getString("jieshao"));
				shangping.setSimgss(rs.getString("simgss"));
				shangping.setJifen(rs.getInt("jifen"));
				shangping.setCommentcount(rs.getInt("commentcount"));
				goodsType.setShangping(shangping);
				typegg typegg = new typegg();
				typegg.setTgname(rs.getString("tgname"));
				goodsType.setTypegg(typegg);
				goodsType.setSid(rs.getInt("sid"));
				goodsType.setSpgvalues(rs.getString("spgvalues"));
				goodsType.setSpgvalues2(rs.getString("spgvalues2"));
				
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}finally {
			try {
				closeAll(rs.getStatement().getConnection(), rs.getStatement(), rs);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return goodsType;
	}

}
